package cn.aws360.boot.extend.sms.starter.controller;

import cn.aws360.boot.base.api.annotation.OpsLog;
import cn.aws360.boot.base.api.constant.enums.OpsTypeEnum;
import cn.aws360.boot.base.api.pojo.response.ResultModel;
import cn.aws360.boot.extend.sms.api.pojo.request.SmsLoginCaptchaQuery;
import cn.aws360.boot.extend.sms.biz.service.SmsService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static cn.aws360.boot.extend.sms.api.constant.SmsConstant.*;

/**
 * @author junnan
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/sms")
@ApiSupport(order = MODULE_SMS_CODE)
@Api(value = MODULE_SMS_NAME, tags = MODULE_SMS_TAGS)
public class SmsController {

    private final SmsService smsService;

    @PostMapping("/login/captcha")
    @OpsLog(title = "发送登录验证码", opsType = OpsTypeEnum.INSERT)
    @ApiOperation(value = "发送登录验证码")
    @ApiOperationSupport(order = 1)
    public ResultModel<Boolean> sendLoginCaptcha(@RequestBody SmsLoginCaptchaQuery loginCaptchaQuery) {
        return ResultModel.ok(smsService.sendLoginCaptcha(loginCaptchaQuery));
    }

}
